﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteContent.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ProjectFitus.Models.Request>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	ViewPage3
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>ViewPage1</h2>

    <table class="beiðnitafla">
        <tr class="beiðnitafla1">
            <th></th>
            <th>
                Titill beiðni:
            </th>
            <th>
                Beiðni sett fram af:
            </th>
            <th>
                Lögð fram dags::
            </th>
            <th>
                Seinast uppfært af
            </th>
            <th>
                Seinast uppfært dags:
            </th>
            <th>
                Staða
            </th>
            <th>
                Tegund beiðni
            </th>
        </tr>

    <% foreach (var item in Model) { %>
    
        <tr class="beiðnitafla2">
            <td>
                <a class="requestEditLinks" onclick="editRequest(<%: item.id %>)" id="<%: item.id %>" name="<%: item.id %>" >Edit</a> |
                <%: Html.ActionLink("Details", "Details", new { id=item.id })%> |
                <%: Html.ActionLink("Delete", "Delete", new { id=item.id })%> 
            </td>
            <td>
                <%:  item.requestTitle %>
            </td>
            <td class="beiðnitafla3"> 
            
                <%= Html.ActionLink( item.User.userName, "Details/"+item.requestedBy, "User") %> 
            </td>
            <td class="beiðnitafla3">
                <%: String.Format("{0:g}", item.dateCreated) %> 
                <%  var lastResponse = item.RequestResponses.Where(p => p.isActive == true).OrderByDescending(p => p.dateCreated).FirstOrDefault();
                    if (lastResponse != null) 
                   {%>
                    <%= Html.ActionLink( lastResponse.User.userName, "Details/"+lastResponse.submittedBy, "User")%>     
            </td>
            <td class="beiðnitafla3">
                 <%: String.Format("{0:g}", lastResponse.dateCreated) %> 
            </td>
            
                <%}
                    else {%>
                    <td></td>
                    <td></td>
                    
                <%}%>      
        <td class="beiðnitafla3">
               <%: item.AssignmentStatusListItem.statusName %>
            </td>
            <td class = "beiðnitafla3">
                <%: item.RequestType1.requestTypeName %>
            </td>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%: Html.ActionLink("Create New", "Create") %>
    </p>
    

    <div id="editRequestWindow"  style="border:1px solid pink; display:none;">

    <input id="editRequestId" name="editRequestId" type="hidden" value="0" />
    <select id="statusId" name="status">
        <option value="statusId1">Óafgreidd</option>
        <option value="statusId2">Í bið</option>
        <option value="statusId3">Hafnað</option>
        <option value="statusId4">Afgreitt</option>
    </select>
    <h4 id="requestType"></h4>
    <p id="requestDescription">
        
    </p>
    
    <label for="responseText">Svar-reitur(eða uppfærslu-reitur):</label>
    
    <textarea id="responseText" cols="50" rows="6"></textarea>

    <p><button id="submitRequestChanges">Staðfesta</button> <button id="stopRequestEdit">Hætta við breytingu</button> </p>
    </div>

    




</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
